package com.hzdl.sbdemo.controller;

import com.hzdl.sbdemo.bean.UserInfo;
import com.hzdl.sbdemo.util.HzdlAjaxResult;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@PropertySource(value = "classpath:application.properties",encoding = "utf-8")
@RestController
@RequestMapping("hello")
public class HelloController {
    @Value("${name1}")
    private String name;
    @RequestMapping("user")
   public UserInfo getUserInfo(){
        UserInfo userInfo=new UserInfo(10000,"张三");
        userInfo.setBirth(new Date());
        userInfo.setPwd("888888");
        userInfo.setDesc("自我介绍");
       return userInfo;
   }
   @RequestMapping("name")
   public  String getName(){
       System.out.println(name);
        return name;
   }
   @RequestMapping("userJson")
    public HzdlAjaxResult userJson(){
       UserInfo userInfo=new UserInfo(10000,"张三");
       userInfo.setBirth(new Date());
       userInfo.setPwd("888888");
       userInfo.setDesc("自我介绍1");
       return HzdlAjaxResult.ok(userInfo);
   }
}
